import "../utils" as Utils
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.12
import Qt.labs.settings 1.0
Rectangle{
    color: "transparent"
    Utils.CheckScenesWarnPage{
    visible: swipeView.currentIndex===1
        anchors.fill: parent
    }

    Rectangle{
        color: "transparent"
        anchors.fill: parent
        visible: swipeView.currentIndex===2
        Rectangle{
            y:136
            anchors.left:parent.left
            color: "#F05252"
            height: 16
            width: 200
        }
        Rectangle{
            y:136
            color: "#F05252"
            anchors.left:parent.left
            height: 120
            width: 16
        }
        Rectangle{
            anchors.left:parent.left
            anchors.bottom: parent.bottom
            anchors.bottomMargin:200
            color: "#F05252"
            height: 16
            width: 200
        }
        Rectangle{
            color: "#F05252"
            anchors.left:parent.left
            anchors.bottom: parent.bottom
            anchors.bottomMargin:200
            height: 120
            width: 16
        }
    }

    Rectangle{
        width: parent.width
        height: 200
        anchors.bottom: parent.bottom
        color: "#0D0F12"
        visible: swipeView.currentIndex === 2
    }
    Rectangle{
        width: parent.width
        height: 136
        color: "#0D0F12"
        visible: swipeView.currentIndex!== 0  && swipeView.currentIndex !== 1
        Image{
            x: 24
            y: 31
            visible: swipeView.currentIndex!== 0  && swipeView.currentIndex !== 1
            width: 224
            height: 64
            source: "qrc:/scraper/imgs/xcmg_main.png"
        }
        Text{
            x: 328
            y: 31
            color: "#FCFCFC"
            text: can_manager.control_mode ? "远程模式" : "观看模式"
            font{
                family: "Microsoft YaHei"
                pixelSize: 40
            }
        }
        Rectangle{
            width: 129
            height: 64
            color: "transparent"
            x:568
            y:36
            Rectangle{
                anchors.left: parent.left             
                anchors.verticalCenter: parent.verticalCenter
                height: 24
                width: 24
                radius: 12
                color: switch(can_manager.mode_status)
                {
                    case 0:"#D79B00";break;
                    case 1:"#00D160";break;
                    case 2:"#F05252";break;
                    default:break;
                }
            }
            Text{
                anchors.right: parent.right             
                anchors.verticalCenter: parent.verticalCenter
                color: "#FCFCFC"
                text: switch(can_manager.mode_status)
                    {
                        case 0:"待机";break;
                        case 1:"运行";break;
                        case 2:"故障 ";break;
                        default:break;
                    }
                font{
                    family: "Microsoft YaHei"
                    pixelSize: 40
                }
            }
        }
        Row{
            spacing: 24
            anchors.right: parent.right
            anchors.rightMargin:72
            anchors.verticalCenter: parent.verticalCenter
            Image{
                width: 64
                height: 64
                source: !can_manager.parking_signal ? "qrc:/imgs/park_2.png" : "qrc:/imgs/park.png" 
            }
            Image{
                width: 64
                height: 64
                source: 0 ? "qrc:/imgs/no_link_1.png" : "qrc:/scraper/imgs/no_link.png"
            }
            Image{
                width: 64
                height: 64
                source: 0 ?  "qrc:/imgs/stop_2.png": "qrc:/scraper/imgs/stop_1.png"
            } 
        }
    }
    // Rectangle{
    //     height: 10
    //     width: parent.width
    //     anchors.bottom:parent.bottom
    //     anchors.bottomMargin:200
    //     color: "black"
    //     visible: swipeView.currentIndex === 3
    //     LinearGradient{
    //         height: 10
    //         width: parent.width
    //         anchors.top: parent.top
    //         start:Qt.point(0,0)
    //         end:Qt.point(parent.width,0)
    //         gradient: Gradient{
    //             GradientStop{position:0.0;color:"#00FFFFFF"}
    //             GradientStop{position:1.0;color:"#FFFFFF"}
    //         }
    //     }
    // }

    //左转向灯
    TurnLight{
        id: turnLeftLight
        visible: can_manager.turn_left_light ? true : false
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 478
        anchors.horizontalCenter: parent.horizontalCenter
    }
    Column{
        id: boardRow
        x: 72
        y:208
        spacing: 64
        visible: swipeView.currentIndex===3
        Utils.DashBoardBeta{
            id: mySpeedItem
            current_speed:(can_manager.speed).toFixed(1)
        }
        Utils.DashBoardBeta{
            id: myoilItem
            display_mode: true
            current_engine: (can_manager.engine_speed).toFixed(1)
        }
    }
    Rectangle{
        id:left_mid_bottom_info
        width: parent.width
        height: 200
        anchors.bottom: parent.bottom
        color: "#0D0F12"
        visible: swipeView.currentIndex === 3

        Rectangle{
            color: "#00000000"
            x:24
            y: 64
            width: 268
            height: 72
            // color: "#000000"
            Image{
                width: 130
                height: 72
                anchors.left:parent.left
                source: "qrc:/scraper/imgs/bottom_icon1.png"
            }
            Text{
                color: "#FCFCFC"  
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                text: can_manager.coolant_temperature.toFixed(0)
                font{
                    family: "Aldrich"
                    pixelSize: 64
                }
            }
        }
        Rectangle{
            height: 120
            width: 2
            x: 324
            y: 40
            color: "transparent"
            LinearGradient{     
                anchors.fill: parent
                start:Qt.point(0,0)
                end:Qt.point(0,parent.height)
                gradient: Gradient{
                    GradientStop{position:0.0;color:"transparent"}
                    GradientStop{position:0.5;color:"#00FFFF"}
                    GradientStop{position:1.0;color:"transparent"}
                }
            }
        }
        Rectangle{
            color: "#00000000"
            x:358
            y: 64
            width: 268
            height: 72
            Image{
                width: 130
                height: 72
                anchors.left:parent.left
                source: "qrc:/scraper/imgs/bottom_icon2.png"
            }
            Text{
                color: "#FCFCFC"
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                text: can_manager.fuel_level.toFixed(0)
                font{
                    family: "Aldrich"
                    pixelSize: 64
                }
            }
        }
        Rectangle{
            height: 120
            width: 2
            x: 658
            y: 40
            color: "transparent"
            LinearGradient{     
                anchors.fill: parent
                start:Qt.point(0,0)
                end:Qt.point(0,parent.height)
                gradient: Gradient{
                    GradientStop{position:0.0;color:"transparent"}
                    GradientStop{position:0.5;color:"#00FFFF"}
                    GradientStop{position:1.0;color:"transparent"}
                }
            }
        }
        Rectangle{
            color: "#00000000"
            x:692
            y: 64
            width: 328
            height: 72
            Image{
                width: 130
                height: 72
                anchors.left:parent.left
                source: "qrc:/scraper/imgs/bottom_icon3.png"
            }
            Text{
                color: "#FCFCFC"
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                text: can_manager.engine_operating_time.toFixed(0)
                font{
                    family: "Aldrich"
                    pixelSize: 64
                }
            }


        }
    }
}